// CommonJS规范中，模块化使用遵循三步骤
// 1. 导入
// 2. 书写代码
// 3. 导出

// 导入url模块
// const url = require('url')
// const DZ = "https://www.baidu.com:3721/html/2107/index.html?floor=2&classroomId=10#pos=main"
const url=require("url");
const address="https://www.baidu.com:3455/2107/hello/world/index?floor=2&id=345#pos=main";
// parse：解析地址的
// 参数1：是待解析的url地址
// 参数2：bool值，默认为false，传递true则表示将query查询字符串部分其形式解析为对象形式，方便获取参数
// console.log(url.parse(DZ));
// console.log(url.parse(DZ,true));
console.log(url.parse(address));
console.log(url.parse(address,true));
// resolve：用于组合url地址，产生新的地址的
// console.log(url.resolve("http://www.qq.com/foo","boo")); // qq.com/boo,相对路径，相对于foo,覆盖foo
// console.log(url.resolve("http://www.qq.com/foo","./boo")); // qq.com/boo,相对路径，相对于foo,覆盖foo
// console.log(url.resolve("http://www.qq.com/foo","/boo")); // qq.com/boo,绝对路径，只写在根目录后
// console.log(url.resolve("http://www.qq.com/foo","boo/coo")); // qq.com/boo/coo
// console.log(url.resolve("http://www.qq.com/foo","boo/coo","/zoo")); // qq.com/boo/coo,不支持3个参数
console.log(url.resolve("https://www.qq.com/foo","boo"));
console.log(url.resolve("http://www.qq.com/foo","./boo"));
console.log(url.resolve("http://www.qq.com/foo","boo/coo"));
console.log(url.resolve("http://www.qq.com/foo","/boo"));
// http://api.demo.com/v1/list
// http://api.demo.com/v1/detail

// const url = "http://api.demo.com/v1";

// const list = url + "/list";